﻿using Microsoft.Graphics.Canvas;
using Microsoft.Graphics.Canvas.Effects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 纸片人.win2dEffectControl.DataClass
{
    public class EdgeDetectionEffectData : EffectOneSourceData
    {
        private EdgeDetectionEffectMode mode;
        private CanvasAlphaMode alphaMode;
        private float blurAmount;
        private float amount=0.5f;
        private bool overlayEdges;

        public bool OverlayEdges { get => overlayEdges; set { overlayEdges = value; OnPropertyChanged(); SetIsChanges(); } }
        public float Amount { get => amount; set { amount = value; OnPropertyChanged(); SetIsChanges(); } }
        public float BlurAmount { get => blurAmount; set { blurAmount = value; OnPropertyChanged(); SetIsChanges(); } }
        public CanvasAlphaMode AlphaMode { get => alphaMode; set { alphaMode = value; OnPropertyChanged(); SetIsChanges(); } }
        public EdgeDetectionEffectMode Mode { get => mode; set { mode = value; OnPropertyChanged(); SetIsChanges(); } }
        #region 属性

        #endregion
        public override ICanvasImage GetEffect(CanvasDevice device, bool compression)
        {
            var source = GetSourceEffect(device, compression);
            if (source == null)
                return null;
            if(alphaMode== CanvasAlphaMode.Ignore)
            {
                AlphaMode = CanvasAlphaMode.Premultiplied ;
            }
           

            var effect = new EdgeDetectionEffect()
            {
                Source = source,
                Mode = Mode,
                AlphaMode = AlphaMode,
                BlurAmount = BlurAmount,
                Amount = Amount,
                OverlayEdges = OverlayEdges,

            };

            return effect;
        }
    }
}
